<template>
  <div class="my_manage">
    <!-- 第一行 -->
    <el-form :inline="true" :model="searchs" class="demo-form-inline" size="small">
      <!-- 文库名称 -->
      <el-form-item label="文库名称">
        <el-input v-model="searchs.name" placeholder="请输入文库名称关键字"></el-input>
      </el-form-item>
      <!-- 图书 -->
      <el-form-item label="所属分类">
        <el-select v-model="searchs.library_classify" placeholder="请选择">
          <el-option label="图书" value="shanghai"></el-option>
        </el-select>
      </el-form-item>
      <!-- 作者 -->
      <el-form-item label="作者">
        <el-input v-model="searchs.author" placeholder="请输入作者关键字"></el-input>
      </el-form-item>
      <!-- 入库人 -->
      <el-form-item label="入库人">
        <el-input v-model="searchs.creator" placeholder="请输入入库人关键字"></el-input>
      </el-form-item>
    </el-form>

    <!-- 状态 -->
    <el-form :inline="true" :model="searchs" class="demo-form-inline" size="small">
      <el-form-item label="状态">
        <el-select placeholder="请选择" v-model="searchs.status">
          <el-option label="已上架" :value="1"></el-option>
          <el-option label="已下架" :value="2"></el-option>
          <el-option label="待上架" :value="3"></el-option>
        </el-select>
      </el-form-item>

      <!-- 时间 -->
      <el-form-item label="活动时间">
        <el-col :span="22">
          <el-date-picker type="date" placeholder="选择日期" style="width: 100%;"></el-date-picker>
        </el-col>
      </el-form-item>
      <!-- 搜索 -->
      <el-form-item>
        <el-button plain @click="onSearch">
          <i class="el-icon-search" />&nbsp;&nbsp;搜索
        </el-button>
      </el-form-item>
      <!-- 重置 -->
      <el-form-item>
        <el-button plain>
          <i class="el-icon-refresh"></i>&nbsp;&nbsp;重置
        </el-button>
      </el-form-item>
    </el-form>
    <!-- 新增文案 -->
    <div class="my_button" @click="$router.push({name: 'shopLibraryedit'})">
      <el-button type="primary" size="small">新增文库</el-button>
    </div>
    <!-- 表格 -->
    <el-table border style="width: 100%" :data="Manage.list" stripe>
      <el-table-column type="selection" width="55" align="center"></el-table-column>
      <el-table-column prop="name" label="文库名称" width="240"></el-table-column>
      <el-table-column prop="library_classify" label="所属分类" width="120" align="center"></el-table-column>
      <el-table-column prop="author" label="作者" width="120" align="center"></el-table-column>
      <el-table-column label="状态" prop="status" width="120" align="center">
        <template
          slot-scope="scope"
        >{{scope.row.status==1 ?"已上架":(scope.row.status =="2"?"已下架":"待上架")}}</template>
      </el-table-column>
      <el-table-column prop="sort" label="序号" width="120" align="center"></el-table-column>
      <el-table-column prop="creator" label="入库人" width="120" align="center"></el-table-column>
      <el-table-column prop="created_at" label="入库时间" width="160" align="center">
        <template slot-scope="scope">{{scope.row.created_at | formatDate}}</template>
      </el-table-column>
      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <el-link size="mini" type="primary">排序</el-link>-
          <el-link
            size="mini"
            type="primary"
            @click="$router.push({name:'shopLibraryedit', query:{id: scope.row.id}})"
          >编辑</el-link>-
          <el-link size="mini" type="primary">上架</el-link>-
          <el-link size="mini" type="primary">删除</el-link>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
     <!-- <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination>
  </div> -->
  </div>
</template>

<script>
import { getLibrary } from '../../api'
export default {
  data() {
    return {
      Manage: [],
      copylist: [],
      searchs: {
        name: '',
        library_classify: '',
        author: '',
        creator: '',
        status: ''
      }
    }
  },
  mounted() {},
  methods: {
    // 搜索
    onSearch() {}
  },
  created() {
    getLibrary().then(res => {
      console.log(res)
      this.Manage = res.data
      this.copylist = res.data
    })
  }
}
</script>

<style lang='scss' scoped>
.my_button {
  margin-bottom: 10px;
}
</style>
